<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>登录页面 - 后台管理系统</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="后台管理系统">
    <meta name="description" content="后台管理系统">
    <meta name="_token" content="{{ csrf_token() }}"/>
    <link href="{{asset('static/css/bootstrap.min.css')}}" rel="stylesheet">
    <link href="{{asset('static/css/materialdesignicons.min.css')}}" rel="stylesheet">
    <link href="{{asset('static/css/style.min.css')}}" rel="stylesheet">
    <link href="{{asset('static/css/admin/login.css')}}" rel="stylesheet">
</head>
<body>
<div class="row lyear-wrapper" style="background-image: url('{{asset("static/images/login-bg-2.jpg")}}'); background-size: cover;">
    <div class="lyear-login">
        <div class="login-center">
            <div class="login-header text-center">
                <a href="index.html">登录 - 后台管理系统</a>
            </div>
            <form action="{{url('/admin/dologin')}}" method="post" id="form1">
                <div class="form-group has-feedback feedback-left">
                    <input type="text" placeholder="请输入您的用户名" class="form-control" name="username" id="username" />
                    <span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
                </div>
                <div class="form-group has-feedback feedback-left">
                    <input type="password" placeholder="请输入密码" class="form-control" id="password" name="password" />
                    <span class="mdi mdi-lock form-control-feedback" aria-hidden="true"></span>
                </div>
                <div class="form-group has-feedback feedback-left row">
                    <div class="col-xs-7">
                        <input type="text" name="captcha" class="form-control" placeholder="验证码" maxlength="4">
                        <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>
                    </div>
                    <div class="col-xs-5">
                        <img src="{{captcha_src('default')}}" class="pull-right" id="captcha" style="cursor: pointer;" onclick="this.src=this.src+'?d='+Math.random();" title="点击刷新" alt="captcha">
                    </div>
                </div>
                <div class="form-group has-feedback feedback-left row login_row" style="display:none;">
                    <div class="col-xs-12">
                        <div class="alert alert-danger login_tip" role="alert" style="margin-bottom:0px;"></div>
                    </div>
                </div>
                <div class="form-group">
                    <button class="btn btn-block btn-primary dologin" type="button">立即登录</button>
                </div>
            </form>
            <hr>
            <footer class="col-sm-12 text-center">
                <p class="m-b-0">Copyright © 2021 版权所有</p>
            </footer>
        </div>
    </div>
</div>
<script type="text/javascript" src="{{asset('static/js/jquery.min.js')}}"></script>
<script type="text/javascript" src="{{asset('static/js/bootstrap.min.js')}}"></script>
<script type="text/javascript" src="{{asset('static/js/bootstrap-notify.min.js')}}"></script>
<script type="text/javascript" src="{{asset('static/js/lightyear.js')}}"></script>
<script type="text/javascript" src="{{asset('static/js/main.min.js')}}"></script>
<script type="text/javascript">
	$(function(){
		$('.dologin').click(function(){
			$.ajax({
				type: $('#form1').attr('method'),
				url: $('#form1').attr('action'),
				data: $('#form1').serialize(),
				dataType: 'json',
				success: function(result){
					if(result.status){
                        lightyear.loading('show');
                        setTimeout(function() {
                            lightyear.loading('hide');
                            lightyear.notify('登录成功，页面即将自动跳转~', 'success', 1000);
                        }, 1000);
						location.href = result.data.url;
					}else{
						var timestamp = new Date().getTime();
						$('#captcha').attr('src',$('#captcha').attr('src') + '?' +timestamp );
						
						$('.login_row').show();
						$('.login_tip').html(result.message);
					}
				},
				error: function(request, status, error) {
					console.log(request.status);
					console.log(request.readyState);
					console.log(status);
				},
			});
		})
		$(document).keyup(function(event){
          if(event.keyCode ==13){
            $(".dologin").trigger("click");
          }
        });
		$.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') }})
	})
</script>
</body>
</html>